import request from '@/utils/request'

// 社区
export const getArticle = (params) => request({
    url: '/community/articles/',
    method: 'GET',
    params
})

// 标签
export const getLabel = () => request({
    url: '/community/labels/',
    method: 'GET'
})

export const createArticle = (data) => request({
    url: '/community/articles/',
    method: 'POST',
    data
})

// 获取商品详情
export const getArticleDetail = (id) => request({
    url: `/community/articles/${id}/`,
    method: 'get'
})

// 获取文章评论（分页）
export const getArticleComments = (articleId, params = {}) => request({
    url: `/community/articles/${articleId}/comment/`,
    method: 'GET',
    params
})

// 发表评论
export const createComment = (data) => request({
    url: '/community/comments/',
    method: 'POST',
    data
})

// 回复评论
export const replyComment = (data) => request({
    url: '/community/comments/',
    method: 'POST',
    data
})

// 获取子评论
export const getSubComments = (parentCommentId, params = {}) => request({
    url: `/community/comments/${parentCommentId}/`,
    method: 'GET',
    params
}) 